package homework;

import org.junit.Test;

import java.util.*;

public class CollectionTest {

    public static void main(String[] args) {

            double a = 25/2;
        System.out.println(a);

            //通过无参构造器 生成的ArrayList对象长度 是0
            ArrayList<String>arr = new ArrayList();

            arr.add("春眠不觉晓，");
            arr.add("处处闻啼鸟。");
            arr.add("夜来风雨声，");
            arr.add("花落知多少。");

            Iterator<String> iterator = arr.iterator();
            iterator.next();
            iterator.next();
            iterator.remove();
            while (iterator.hasNext()){
                String next = iterator.next();
                System.out.println("----"+next);
            }
    }

    @Test
    public void ListIterator(){
        HashMap<Integer,String> map = new HashMap<>();

        map.put(1,"查三1");
        map.put(2,"查三2");
        map.put(3,"查三3");
        map.put(4,"查三4");
        map.put(5,"查三5");
        map.put(6,"查三1");

        //获取到key 里头是所有的值
        Set<Integer> integers = map.keySet();
        for (Integer a :
                integers) {
            System.out.println("key->"+a);
            System.out.println("value->"+map.get(a));
        }

        //获取到 value里头的所有的值
        Collection<String> values = map.values();
        for (String s:
             values) {
            System.out.println(s);
        }
    }
}


